say 'Sorry, due to restrictions in RX, you''ll have to place "'pname'" somewhere where the path does not resolve with a space in it.'
exit 10
end
if(args='') then
do
if(reqtools) then url=rtgetstring(,'Enter URL:','Enter URL')
else do;say 'Enter URL:';parse pull url;end
if(url='') then
do
say 'No URL entered .. exiting!'
exit
end
if(pos('://',url)=0) then url='http://'url
call Play()
end
else if ~open(file,args,R) then
do
say 'Unable to open file containing URL!!!'
exit 10
end
else do x=1 while ~eof(file)
url=readln(file);url=strip(url,'T',d2c(13))
if(url='') then iterate x
if(~abbrev(url,'http://',7) & ~abbrev(url,'pnm://',6)) then iterate x
call Play()
end
if ~found then
do
say 'No supported URLs found!!!'
exit 10
end
exit
/*** PROCEDURES ***/
Play:
if(upper(right(url,4))='.RAM' | upper(right(url,4))='.RPM') then
do
if(pos('http://',url)=1) then url=substr(url,8);if(pos('pnm://',url)=1) then url=substr(url,7);port='80';crlf=d2c(13)''d2c(10);lookup=1
if(pos('/',url)>0) then do;host=substr(url,1,pos('/',url)-1);path=substr(url,pos('/',url));end
else do;host=url;path='/';end
if(pos(':',host)>0) then do;port=substr(host,pos(':',host)+1);host=substr(host,1,pos(':',host)-1);end
if ~GetHost('HOST',host) then;if(datatype(compress(host,'.'),'N')) then do;host.HOSTADDRLIST.0=host;lookup=0;end;else do;say 'Unable to lookup host!!!';iterate x;end
sock=Socket('INET','STREAM','IP');if sock<0 then do;say 'Unable to create socket!!!';iterate x;end
if(pos(':',host)>0) then do;port=substr(host,pos(':',host)+1);host=substr(host,1,pos(':',host)-1);end
if(savepath~='') then
do
if(right(savepath,1)~=':' & right(savepath,1)~='/') then savepath=savepath'/'
filename=substr(path,lastpos('/',path)+1);save=1
end
crlf=d2c(13)''d2c(10);lookup=1
if ~GetHost('HOST',host) then;if(datatype(compress(host,'.'),'N')) then do;host.HOSTADDRLIST.0=host;lookup=0;end;else do;setclip(ratmp,'Unable to lookup host!!!');return 10;end
sock=Socket('INET','STREAM','IP');if sock<0 then do;setclip(ratmp,'Unable to create socket!!!');return 10;end
if Connect(sock,'CONN')<0 then do;if(lookup) then setclip(ratmp,'Sorry, server is down, unable to stream data!');else setclip(ratmp,'Host does not exist!!!');return 10;end